<!--
 * @Author: 贾博林 11457230+jabolin@user.noreply.gitee.com
 * @Date: 2022-10-21 15:19:11
 * @LastEditors: 贾博林 11457230+jabolin@user.noreply.gitee.com
 * @LastEditTime: 2022-10-25 20:54:29
 * @FilePath: \v-shop\code\src\views\orders.vue
 * @Description:orders订单管理页面
-->
<template>
  <div>

    <!-- 面包屑 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <br>


    <!-- 卡片 -->
    <el-card>
      <!-- 搜索框 -->
      <el-input placeholder="请输入内容" v-model="keyword" class="input-with-select" style="width:428px">
        <el-button slot="append" icon="el-icon-search"></el-button>
      </el-input>
      <br>
      <br>

      <!-- 表单 -->
      <el-table :data="orders" border style="width: 100%">
        <el-table-column fixed type="index" label="#">
        </el-table-column>
        <el-table-column prop="order_number" label="订单编号">
        </el-table-column>
        <el-table-column prop="order_price" label="订单价格">
        </el-table-column>
        <el-table-column prop="pay_status" label="是否付款">
          <!-- 插槽标签 -->
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_status == 0">未付款</el-tag>
            <el-tag type="success" v-if="scope.row.pay_status == 1">已付款</el-tag>

          </template>

        </el-table-column>
        <el-table-column prop="is_send" label="是否发货">
        </el-table-column>
        <el-table-column prop="create_time" label="下单时间">
          <!-- 插槽时间 -->
          <template slot-scope="scope">
            {{ scope.row.create_time | time }}
          </template>

        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
            <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>


      <!-- 分页 -->
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="params.pagenum" :page-sizes="[1, 2, 3, 4]" :page-size="params.pagesize"
        layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>

    </el-card>


  </div>
</template>

<script>

import { orders } from '../http/orders/api'
export default {
  name: 'orders',
  data() {
    return {
      keyword: '',
      orders: [],
      // 分页
      params: {
        pagenum: 1,
        pagesize: 4,
      },
      total: 0,
    };
  },

  components: {},

  computed: {},

  // 钩子函数
  created() {
    this.getdata()
  },


  // 过滤时间格式
  filters: {
    time(val) {
      return new Date(val).toLocaleString()
    }
  },
  // 方法
  methods: {

    // 分页
    handleSizeChange(val) {
      this.params.pagesize = val
      this.getdata()
    },
    handleCurrentChange(val) {
      this.params.pagenum = val
      this.getdata()
    },
    // 渲染
    getdata() {
      orders(this.params).then(res => {
        console.log(res, "渲染");
        this.orders = res.data.data.goods
        // 渲染分页
        this.total = res.data.data.total
      })

    }
  },
  watch: {},
  mixins: []
}

</script>
<style  scoped>

</style>